import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from python_ai.common.xcommon import sep

df = pd.DataFrame([['green', 'a'],
                   ['green', 'b'],
                   ['blue', 'a'],
                   ['blue', 'b'],
                   ['green', 'a']])
sep('onehot')
# get_dummies is just onehot encoder
df1 = pd.get_dummies(df)
print(type(df1))
print(df1)

sep('onehot on col0')
df2 = pd.get_dummies(df[0])
print(df2)

df = pd.DataFrame([['green', 'a'],
                   ['green', 'b'],
                   ['blue', 'a'],
                   ['blue', 'b'],
                   ['green', 'a']],
                  columns=['color', 'letter'])
sep('onehot')
# get_dummies is just onehot encoder
df1 = pd.get_dummies(df)
print(type(df1))
print(df1)

sep('onehot on col0')
df2 = pd.get_dummies(df.iloc[:, 0])
print(df2)